﻿using AutoMapper;
using Outpatient.Doman.Hospitalization;
using OutpatientApi.DTO;


namespace OutpatientApi.Common
{
    /// <summary>
    /// AutoMapper配置文件
    /// </summary>
    public class MapperingProfil : Profile
    {
        public MapperingProfil()
        {
            // 配置 Create_medicinesDto 到 Medicine 的映射
            CreateMap<Create_medicinesDto, Medicine>()
                .ForMember(dest => dest.MedicineId, opt => opt.Ignore()) // 忽略主键，因为是新增操作
                .ForMember(dest => dest.AdmissionId, opt => opt.Ignore()) // 忽略外键，可能需要单独设置
                .ForMember(dest => dest.IsDelete, opt => opt.MapFrom(src => false)); // 设置默认值

            // 配置 UpdateMedicineDto 到 Medicine 的映射
            CreateMap<UpdateMedicineDto, Medicine>()
                .ForMember(dest => dest.AdmissionId, opt => opt.Ignore()) // 忽略外键，保持原值
                .ForMember(dest => dest.IsDelete, opt => opt.Ignore()); // 忽略删除标志，保持原值
        }
    }
}
